<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js" type="text/javascript" charset="UTF-8"></script>
</head>
<body>
    <div id="app">
        <input type="button" value="计时开始" @click="start"><br>
        {{time}}<br>
        <input type="button" value="结束" @click="end">
    </div>
    <script>
        var vm =new Vue({
            el:"#app",
            data:{
                time:0,
                timer:null
            },
            methods:{
                start:function(){
                    this.timer = setInterval(()=>{
                        this.time++;
                    },1000)
                },
                end:function(){
                    clearInterval(this.timer);
                }
            }
        })
    </script>
</body>
</html>